<!---
 
  Copyright (c) 2010, Cristian Costantini - cristian@millemultimedia.it
  
  FileManager is licensed under the terms of the Open Source GPL 3.0 license. 
	
	http://www.gnu.org/licenses/gpl.html
  
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
--->

<cfcomponent output="false">

	<cfset variables.proxyId = CreateUUId() />
	<cfset variables.scope = "request" />
	<cfset variables.core = "fileManager" />
	<cfset variables.serviceName = "FileManager" />
	
	<cffunction name="callMethod" access="private" returntype="any">
		<cfargument name="methodName" type="string" required="true" />
		<cfargument name="args" type="struct" required="true" />
		<cfset var target = evaluate( "#variables.scope#.#variables.core#" ) />
		<cfset var result = "" />
		
		<cfset result = target.invokeServiceMethod( variables.serviceName, arguments.methodName, arguments.args ) />
					  
		<cfreturn result />
	</cffunction>
	
	<cffunction name="deleteDirectory" access="remote" returntype="Any">
		<cfargument name="directoryPath" type="string" required="false" />
		<cfargument name="throwIfMissing" type="boolean" required="false" />
		<cfset var result = callMethod( "deleteDirectory", arguments ) />
		<cfif isDefined('result')><cfreturn result /></cfif>
	</cffunction>

	<cffunction name="renameDirectory" access="remote" returntype="Any">
		<cfargument name="directoryPath" type="string" required="false" />
		<cfargument name="newDirectory" type="string" required="false" />
		<cfset var result = callMethod( "renameDirectory", arguments ) />
		<cfif isDefined('result')><cfreturn result /></cfif>
	</cffunction>

	<cffunction name="copyDirectory" access="remote" returntype="Any">
		<cfargument name="source" type="string" required="false" />
		<cfargument name="destination" type="string" required="false" />
		<cfset var result = callMethod( "copyDirectory", arguments ) />
		<cfif isDefined('result')><cfreturn result /></cfif>
	</cffunction>

	<cffunction name="getFiles" access="remote" returntype="Any">
		<cfargument name="node" type="string" required="false" />
		<cfargument name="col" type="string" required="false" />
		<cfargument name="sort" type="string" required="false" />
		<cfargument name="start" type="string" required="false" />
		<cfargument name="limit" type="string" required="false" />
		<cfset var result = callMethod( "getFiles", arguments ) />
		<cfif isDefined('result')><cfreturn result /></cfif>
	</cffunction>

	<cffunction name="getIcoExtensionList" access="remote" returntype="Any">

		<cfset var result = callMethod( "getIcoExtensionList", arguments ) />
		<cfif isDefined('result')><cfreturn result /></cfif>
	</cffunction>

	<cffunction name="download" access="remote" returntype="Any">
		<cfargument name="download" type="string" required="false" />
		<cfset var result = callMethod( "download", arguments ) />
		<cfif isDefined('result')><cfreturn result /></cfif>
	</cffunction>

	<cffunction name="createDirectory" access="remote" returntype="Any">
		<cfargument name="directoryPath" type="string" required="false" />
		<cfset var result = callMethod( "createDirectory", arguments ) />
		<cfif isDefined('result')><cfreturn result /></cfif>
	</cffunction>

	<cffunction name="renameFile" access="remote" returntype="Any">
		<cfargument name="filePath" type="string" required="false" />
		<cfargument name="newFile" type="string" required="false" />
		<cfset var result = callMethod( "renameFile", arguments ) />
		<cfif isDefined('result')><cfreturn result /></cfif>
	</cffunction>

	<cffunction name="getDirectories" access="remote" returntype="Any">
		<cfargument name="node" type="string" required="false" />
		<cfargument name="col" type="string" required="false" />
		<cfargument name="sort" type="string" required="false" />
		<cfset var result = callMethod( "getDirectories", arguments ) />
		<cfif isDefined('result')><cfreturn result /></cfif>
	</cffunction>

	<cffunction name="deleteFile" access="remote" returntype="Any">
		<cfargument name="filePath" type="string" required="false" />
		<cfset var result = callMethod( "deleteFile", arguments ) />
		<cfif isDefined('result')><cfreturn result /></cfif>
	</cffunction>

	<cffunction name="moveFile" access="remote" returntype="Any">
		<cfargument name="source" type="string" required="false" />
		<cfargument name="destination" type="string" required="false" />
		<cfset var result = callMethod( "moveFile", arguments ) />
		<cfif isDefined('result')><cfreturn result /></cfif>
	</cffunction>

	<cffunction name="moveDirectory" access="remote" returntype="Any">
		<cfargument name="source" type="string" required="false" />
		<cfargument name="destination" type="string" required="false" />
		<cfset var result = callMethod( "moveDirectory", arguments ) />
		<cfif isDefined('result')><cfreturn result /></cfif>
	</cffunction>

	<cffunction name="copyFile" access="remote" returntype="Any">
		<cfargument name="source" type="string" required="false" />
		<cfargument name="destination" type="string" required="false" />
		<cfset var result = callMethod( "copyFile", arguments ) />
		<cfif isDefined('result')><cfreturn result /></cfif>
	</cffunction>


</cfcomponent>
